' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2024.09.09.00.00]) on 2025.07.02 at 22:07 (Coordinated Universal Time)
' This program by Charlie Veniot is a port and mod of Antoni Gual Via's program
' shared with the "BASIC, QBasic, GWBasic computer programming"
' Facebook group (https://www.facebook.com/share/p/15t3dMR6r2/)
' The colour of the LED program can be altered by adding one of 63 colour codes (1-63)
' for this program's screen mode 17 (which uses the "p256" colour mode).
' screen mode documentation: https://bam-progreference.tiddlyhost.com/?target=Bookmarks%3A%3ASCREEN%20Modes#Home
'
' Example URL with colour code 15 as a preference:
' https://basicanywheremachine.neocities.org/sample_programs/DRAW%20DIGITAL%20CLOCK.prod.run?color=15
' 🟡🟡🟡 Declarations
DECLARE SUB digit7( n%, x%, y%, c%, s% )
DECLARE FUNCTION UrlParm$(key$)
DEFINT a-z
DIM b(0 TO 5)
' 🟡🟡🟡 Initialization
SCREEN _NEWIMAGE( 544, 130, 17 )
b(0) = -1: b(1) = -1: b(2) = -1: b(3) = -1: b(4) = -1: b(5) = -1
c = VAL( NVL$( UrlParm$( "color" ), 59 ) )
s = 12
GOSUB DrawColons
' 🟡🟡🟡 Main Program
DO
t$ = TIME$
FOR i = 0 TO 5
a = VAL( MID$( t$, 1 + INT( i * 1.5 ), 1 ) )
' change digit only if changed
IF a <> b(i) THEN digit7 (a, 20 + INT(i * 1.5) * (4 + 5 * s), 20, c, s)
b(i) = a
NEXT
SLEEP 1
LOOP
END
' 🟡🟡🟡 Procedures / Functions
DrawColons:
DRAW "c=" + c + "s=" + s
DRAW "bm172,84u2r2d2l2 bm +1,-12 u2r2d2l2"
PAINT( 176, 80 ), c, c : PAINT( 177, 44 ), c, c
DRAW "bm364,84u2r2d2l2 bm +1,-12 u2r2d2l2"
PAINT( 368, 80 ), c, c : PAINT( 369, 44 ), c, c
RETURN
SUB digit7 (n, x, y, c, s)
' 1
'2 3
' 4
'5 6
' 7
CONST ang = 84
DIM i AS INTEGER
bar$ = "E2r10f2g2l10h2"
s4 = s / 4
'set visible bars for each figure
SELECT CASE n
CASE 0: a1 = c: a2 = c: a3 = c: a4 = 0: a5 = c: a6 = c: a7 = c
CASE 1: a1 = 0: a2 = 0: a3 = c: a4 = 0: a5 = 0: a6 = c: a7 = 0
CASE 2: a1 = c: a2 = 0: a3 = c: a4 = c: a5 = c: a6 = 0: a7 = c
CASE 3: a1 = c: a2 = 0: a3 = c: a4 = c: a5 = 0: a6 = c: a7 = c
CASE 4: a1 = 0: a2 = c: a3 = c: a4 = c: a5 = 0: a6 = c: a7 = 0
CASE 5: a1 = c: a2 = c: a3 = 0: a4 = c: a5 = 0: a6 = c: a7 = c
CASE 6: a1 = c: a2 = c: a3 = 0: a4 = c: a5 = c: a6 = c: a7 = c
CASE 7: a1 = c: a2 = 0: a3 = c: a4 = 0: a5 = 0: a6 = c: a7 = 0
CASE 8: a1 = c: a2 = c: a3 = c: a4 = c: a5 = c: a6 = c: a7 = c
CASE 9: a1 = c: a2 = c: a3 = c: a4 = c: a5 = 0: a6 = c: a7 = c
END SELECT
' scale and locate bars
DRAW "s=" + s
' draw bars
FOR i = 1 TO 7
SELECT CASE i
CASE 1: xx = x + 3 * s4 : yy = y + 0 * s4 : cc = a1 : an = 0
CASE 2: xx = x + 1 * s4 + 1 : yy = y + 15 * s4 - 1 : cc = a2 : an = ang
CASE 3: xx = x + 16 * s4 + 2 : yy = y + 15 * s4 - 1 : cc = a3 : an = ang
CASE 4: xx = x + 2 * s4 : yy = y + 16 * s4 - 2 : cc = a4 : an = 0
CASE 5: xx = x + 1 * s4 - 2 : yy = y + 32 * s4 - 6 : cc = a5 : an = ang
CASE 6: xx = x + 15 * s4 + 2 : yy = y + 32 * s4 - 6 : cc = a6 : an = ang
CASE 7: xx = x + 1 * s4 : yy = y + 33 * s4 - 7 : cc = a7 : an = 0
END SELECT
DRAW "bm=" + xx + ",=" + yy + "ta=" + an + "c=" + cc + bar$
PAINT( xx + CHOOSE(i,15,0,0,15,0,0,15), yy + CHOOSE(i,0,-10,-10,0,-10,-10,0) ), cc, cc
NEXT
END SUB
FUNCTION UrlParm$(key$)
UrlParm$ = ""
keyPos% = INSTR( UCASE$( UrlQueryString$ ), [ UCASE$( key$ ) + "=" ] )
IF keyPos% THEN
step1$ = RIGHT$( UrlQueryString$, [ LEN( UrlQueryString$ ) - keyPos% - LEN( key$ ) ] )
step2% = INSTR(step1$, "&")
UrlParm$ = IFF( step2%, [ LEFT$( step1$, step2% - 1 ) ], step1$ )
END IF
END FUNCTION